<!DOCTYPE html>
<html lang="en">
<head>
<title>教师信息管理系统</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link href="../css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link rel="stylesheet" href="../css/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="../css/uniform.css" />
<link rel="stylesheet" href="../css/select2.css" />
<link rel="stylesheet" href="../css/matrix-style2.css" />
<link rel="stylesheet" href="../css/matrix-media.css" />
<link href="../font-awesome/css/font-awesome.css" rel="stylesheet" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
  <link href="../css/bootstrap-responsive.min.css" rel="stylesheet">

</head>
<body>

<div id="content">
  <div id="content-header">
      <h1>专业教师基本情况</h1>
  </div>

  <div class="container-fluid">
    <div>
      <form class="form-horizontal" style="display: inline-block; ">
        <div class="control-group" style="display: inline-block;">
          <span class="control-label">姓名：</span>
          <div class="controls">
            <input id="name" type="text"  />
          </div>
        </div>
        <div class="control-group" style="display: inline-block; ">
          <span class="control-label">身份证号：</span>
          <div class="controls">
            <input id="cert_num" type="text"  />
          </div>
        </div>
        <div class="control-group" style="display: inline-block; ">
          <span class="control-label">参加工作时间：</span>
          <div class="controls">
            <input id="startTime" type="date" />-至-
            <input id="endTime" type="date" />
          </div>
        </div>
      </form>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <button id="su" class="btn btn-warning" style="display: inline-block; ">搜索</button>
    </div>
    <hr>
    <div class="row-fluid">
      <div class="span12">
        <form action="/basicInfo/leadOutAll" method="post" style="display: inline-block;">
          <input id="cuId2" name="cuId" type="text" style="display: none" >
          <input type="submit" class="btn btn-info btn-large" style="border-radius: 5px"; value="全部导出";>
        </form>
        <div class="widget-box">
          <div class="widget-title"> <span class="icon">
            </span>
            <h5>专业教师基本情况</h5>
          </div>
          <div class="widget-content nopadding">

            <table id="t1" class="table table-bordered table-striped" frame="box">
              <thead>
                <tr >
                  <th rowspan="2">编号</th>
                  <th rowspan="2" >姓名</th>
                  <th rowspan="2" >证件类型</th>
                  <th rowspan="2">证件号码</th>
                  <th rowspan="2">性别</th>
                  <th rowspan="2">出生年月</th>

                  <th rowspan="2">专业技术职务</th>
                  <th rowspan="2">最终学位</th>
                  <th colspan="4">本科学历</th>
                  <th colspan="4">硕士学历</th>
                  <th rowspan="2">参加工作时间</th>

                  <th rowspan="2">任教时间</th>
                  <th rowspan="2">到本专业任教时间</th>
                  <th rowspan="2">是否有行业经历</th>
                  <th rowspan="2">中青年教师实践教学能力培训</th>
                  <th rowspan="2">研究生导师</th>
                  <th rowspan="2">操作</th>
                </tr>
                <tr>
                  <th>学位</th>
                  <th>所学专业</th>
                  <th>取得学位时间</th>
                  <th>毕业学校</th>
                  <th>学位</th>
                  <th>所学专业</th>
                  <th>取得学位时间</th>
                  <th>毕业学校</th>
                </tr>
              </thead>
              <tbody id="tbody">

              </tbody>
            </table>
        <div class="pagination" style="margin-left: 70%">
          <ul>
            <li><a href="#" id="first">第一页</a></li>
            <li><a href="#" id="previous">上一页</a></li>
            <li><a href="#" pageNum="1">1</a> </li>
            <li><a href="#" pageNum="2">2</a></li>
            <li><a href="#" pageNum="3">3</a></li>
            <li><a href="#" pageNum="4">4</a></li>
            <li><a href="#" pageNum="5">5</a></li>
            <li><a href="#" id="next">下一页</a></li>
            <li><a href="#" id="last">最后一页</a></li>

            <li><a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <span id="span2"></span>&nbsp;&nbsp;共<span id="span1"></span>条记录
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</a></li>
          </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script src="http://www.jq22.com/jquery/jquery-1.7.1.js"></script>
<script src="../js/jquery.ui.custom.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootstrap-colorpicker.js"></script>
<script src="../js/bootstrap-datepicker.js"></script>

<script src="../js/masked.js"></script>
<script src="../js/jquery.uniform.js"></script>
<script src="../js/select2.min.js"></script>
<script src="../js/matrix.js"></script>
<script src="../js/matrix.form_common.js"></script>
<script src="../js/wysihtml5-0.3.0.js"></script>
<script src="../js/jquery.peity.min.js"></script>
<script src="../js/bootstrap-wysihtml5.js"></script>
<script type="text/javascript" src="../js/jquery.cookie.js"></script>
<script src="../js/tool.js"></script>

<script type="text/javascript">
  $(function () {
    queryPage(1);
    $("#su").click(function () {
      queryPage(1);
    })
    $(".pagination a").bind("click",function(){
      var num = $(this).attr("pageNum");
      if (num<=lastPage){
        queryPage(num);
      }
      if ($(".pagination a").attr("pageNum")==num){
        $(this).parent("li").attr("class","active");
      }
    });
    $("#remove").live("click",function() {
      var r = confirm("\t确定删除？")
      if (r == true) {
        var eid = $(this).attr("eid");
        $.ajax({
          url:"../basicInfo/byCuId/"+ eid,
          type:"delete",
          data:{},
          dataType:"json",
          success:function (result) {
            if (result.resp_code == "0") {
              alert(result.resp_msg);
              window.location.href = "basics.html";
            }else {
              $("#span1").text(result.resp_msg);
            }
          }
        })
      }
    })
  })

  //表格填充函数
  function queryPage(pageNum){
    var name=$("#name").val();
    var cert_num=$("#cert_num").val();
    var startTime=$("#startTime").val();
    var endTime=$("#endTime").val();
    //当前页码
    pageNum= pageNum==undefined?1:pageNum;
    //页码的有效性判断
    $.get("/basicInfo/findAllUsers",{name:name,certNum:cert_num,startTime:startTime,endTime:endTime,page:pageNum,limit:5},function(result){
      console.log(result)
      var final="";
      var degree0="";var major0="";var studyingTime0="";var graduaTime0="";var school0="";
      var degree1="";var major1="";var studyingTime1="";var graduaTime1="";var school1="";
      var workTime="";var teachTime="";var atTime="";var isWork="";var train="";var supervisor="";
      //填充数据到tbody
      $("#tbody").empty();//清除之前的内容
      $(result.datas.data).each(function(index,basicInfo){
        if (basicInfo.educations!=""){
          $(basicInfo.educations).each(function (index1,education) {
             final=education.certificate;
          })
        }
        var educations0=basicInfo.educations[0];
        if (educations0!=undefined){
          degree0=educations0.degree;
          major0=educations0.major;
          studyingTime0=educations0.studyingTime;
          graduaTime0=educations0.graduaTime;
          school0=educations0.school;
        }
        var educations1=basicInfo.educations[1];
        if (educations1!=undefined){
          degree1=educations1.degree;
          major1=educations1.major;
          studyingTime1=educations1.studyingTime;
          graduaTime1=educations1.graduaTime;
          school1=educations1.school;

        }
        var work=basicInfo.work;
        if (work!=undefined){
          workTime=work.workTime;
          teachTime=work.teachTime;
          atTime=work.atTime;
          isWork=work.isWork;
          train=work.train;
          supervisor=work.supervisor;
        }
        $("#tbody").append(
                " <tr>"+
                "<td>"+(index+1)+"</td>"+
                "<td>"+basicInfo.name+"</td>"+
                "<td >"+basicInfo.certType+"</td>"+
                "<td >"+basicInfo.certNum+"</td>"+
                "<td>"+basicInfo.sex+"</td>"+
                "<td >"+basicInfo.birthday+"</td>"+
                "<td >"+basicInfo.skillJob+"</td>"+
                "<td >"+final+"</td>"+

                "<td>"+degree0+"</td>"+
                "<td>"+major0+"</td>"+
                "<td>"+studyingTime0+"-"+graduaTime0+"</td>"+
                "<td>"+school0+"</td>"+

                "<td>"+degree1+"</td>"+
                "<td>"+major1+"</td>"+
                "<td>"+studyingTime1+"-"+graduaTime1+"</td>"+
                "<td>"+school1+"</td>"+

                "<td>"+workTime+"</td>"+
                "<td>"+teachTime+"</td>"+
                "<td>"+atTime+"</td>"+
                "<td>"+isWork+"</td>"+
                "<td>"+train+"</td>"+
                "<td>"+supervisor+"</td>"+
                "<td>"+
                "<a href='#' id='remove' class='icon-trash' eid="+basicInfo.cuId+" >删除</a></td>"+
                "</tr>"
        );
      })
      //给按钮添加对应的数值
      var num = pageNum;
      var count=result.datas.count;
      lastPage=(count/5)%1===0?(count/5):parseInt(count/5)+1;
      $("a#first").attr("pageNum",1);
      $("a#previous").attr("pageNum",num-1<1?1:num-1);
      $("a#next").attr("pageNum",num+1>lastPage?lastPage:num+1);
      $("a#last").attr("pageNum",lastPage);
      $("span#span1").text(count);
      $("span#span2").text("第"+num+"页/共"+lastPage+"页");

      $("#pageNum").val(num);

    },"json");

  }
</script>

</body>
</html>
